


<%@ include file="sangertablestart.jsp"%> 







<% 
// if logged in the user can do more with the DAS sources
if ( email != null ) {
%>
	
	<form id="dassourceaction" name="dassourceaction" action="DasSourceAction" method="POST" >
	
	<tr class="row0top">
	
	<td colspan="6">Select: <a href="#" onClick="checkUncheckAll(true);">All</a>
	<a href="#" onClick="checkUncheckAll(false);">None</a>
	</td>
	
	<td align="right" colspan="3">action
		<select name="action" onChange="submitAction(this.form.action);">
		<option value="">select ...</option>
		<option value="validate">   validate</option>

		<% if ( (findAction != null) && (findAction.equals("showmine"))){ %>
		<option value="add">   add to project</option>
		<option value="share">   share ownership</option>
		<option value="unown">   decline ownership</option>
		<option value="delete">   delete</option>

		<%} else {%>
		<option value="claim">   claim ownership</option>
		<%} %>
		</select>
	</td>
	</tr>
	
	<tr class="row0bottom">
<%	
} else {
%>
<tr class="row0">
<%} %>


	<td><b>pos</pos></td>
	<td><b><a href="listServices.jsp?sort=id<%=paramstring%><%=reversestring%>">id</a></b></td>

	<td><b>clients</b></td>

	<td><b>
		<a href="listServices.jsp?sort=nickname<%=paramstring%><%=reversestring%>">nickname</a>
	</b></td>

	<td><b>
		<a href="listServices.jsp?sort=status<%=paramstring%><%=reversestring%>">status</a>
	</b></td>

	<td><b>
		<a href="listServices.jsp?sort=capabilities<%=paramstring%><%=reversestring%>">capabilities</a>
	</b></td>

	<td><b>
		<a href="listServices.jsp?sort=coordinateSystem<%=paramstring%><%=reversestring%>">coordinateSystem</a>
	</b></td>

	<td><b>
		<a href="listServices.jsp?sort=description<%=paramstring%><%=reversestring%>">description</a>
	</b></td>
	
	<td><a href="listProjects.jsp">project</a></td>

</tr>



<%
	int i = 0;
	int numberservers = 0;
	if (s != null) {
		numberservers = s.length;
	}

	int twodays = 1000 * 60 * 60 * 24 * 2;
	Date now = new Date();

	for (i = 0; i < numberservers; i++) {

		if ((i < pos) || (i > (pos + stepsize - 1)))
			continue;

		DasSource ds = s[i];

		// color column

		boolean active = true;
		if (ds.getLeaseDate().getTime() < (now.getTime() - twodays)) {
			active = false;
			if (i % 2 != 0) {
%>
<tr class="row1" valign="top">
	<%
	} else {
	%>

<tr class="row2" valign="top">
	<%
			}
			} else {
				if (i % 2 != 0) {
	%>

<tr class="row1" valign="top">
	<%
	} else {
	%>

<tr class="row2" valign="top">
	<%
			}
			}

			// init some variables
			String[] capabs = ds.getCapabilities();
			String [] validCapabs=ds.getValidCapabilities();
			for(int vCaps=0;vCaps<validCapabs.length;vCaps++){
			System.out.println("valid cap ="+validCapabs[vCaps]);
			}
			DasCoordinateSystem[] coordSys = ds.getCoordinateSystem();

			String testCode = "";

			boolean canFeatures = false;
			if (coordSys.length > 0) {
				testCode = coordSys[0].getTestCode();
				for (int j = 0; j < capabs.length; j++) {
			String capability = capabs[j];
			if (capability.equals("features"))
				canFeatures = true;
				}
			}

			String url = ds.getUrl();
			String nickname = ds.getNickname();
		
	%>

	<td nowrap valign="top" ><% if (email != null ) { 
		%><input type="checkbox" name="DS_ID" value="<%=ds.getId() %>"/><%
	}
	%><%=i + 1%><% 
		if ( coord.userOwnsASource(user,new DasSource[]{ds})) {
			%>
			<div title="header=[owner] body=[I am owner of this DAS source]"><img src="img/kuser.png"/></div>
			<div title="header=[edit] body=[edit the registration information]"><a href="editServer.jsp?auto_id=<%=ds.getId() %>"><img src="img/pencil16x16.png" alt="edit"/></a></div>				
			<% 
		}
	%></td>
	<td nowrap><div title="header=[description] body=[<%=ds.getDescription()%>]" ><%=ds.getId()%></div>
	
	<div id="dassourceactions" title="header=[show details] body=[<%=ds.getDescription() %> ]"><a href="showdetails.jsp?auto_id=<%=ds.getId()%>"> 
				<img src="img/messagebox_info16x16.png" border="0" alt="details"
				onMouseOver="window.status='show details'; return true;"
				onMouseOut="window.status=' '; return true;"/>
				</a></div>			
			<div id="dassourceactions" title="header=[validate] body=[validate the <%=ds.getNickname()%> server]"><a href="validateServer.jsp?auto_id=<%=ds.getId()%>"> 
				<img 	src="img/ok16x16.png" border="0" alt="validate"
				onMouseOver="window.status='validate'; return true;"
				onMouseOut="window.status=' '; return true;"></a>
				</div>
<!--			<div id="dassourceactions" title="header=[send to friend] body=[notify a friend about the <%=ds.getNickname()%> server]">-->
<!--				<a href="sendToFriend.jsp?auto_id=<%=ds.getId()%>"> -->
<!--				<img src="img/mail_post_to16x16.png" boder="0" alt="edit"-->
<!--				onMouseOver="window.status='send to friend'; return true;"-->
<!--				onMouseOut="window.status=' '; return true;"></a>-->
<!--				</div>-->
		

	</td>

	<%
	// the clients icons
	%>
	<td>
	<div id="clienticons">
	<!--  icons here --> <%
						if (canFeatures && active) {

						AutoActivation[] aas = activCreator.getAllActivationURLs(ds
						.getUrl());

						for (int l = 0; l < aas.length; l++) {
					AutoActivation aa = aas[l];
					DasClient client = aa.getClient();
			%>
			<div
				title="header=[activate in das client] body=[folow this link to activate this DAS source in the DAS client <%=client.getName() %>]">
			<a href="<%=aa.getURL(ds)%>"> <%
								if (client.getIconPath() != null) {
								out.print("<img src=\"" + client.getIconPath()
								+ "\" border=\"0\"/>");
							} else {
								out.print(client.getName());
							}
					%> </a></div>
			<%
 							}
 							}

 							
 					%>
		</div>
	</td>

	<td>
	<%
				if (!active) 
				out.print("<i>");
	%>
	<div title="header=[description] body=[<%=ds.getDescription()%>]"><%=ds.getNickname()%></div>
	<%
 			if (!active)
 			out.print("</i>");
				
 %>
	</td>

	<td>
	<%
	if (!active) {
	%> <div title="header=[server down?] body=[it was not possible to validate this server in > 2 days]"><a href="validateServer.jsp?auto_id=<%=ds.getId()%>"><img
		src="img/messagebox_warning.png"></a></div> <%
 			} else {

 			if ( url.length() > 7 )	
	 			url = url.substring(7, url.length());
 			if (url.length() > 40) {
 		url = (url.substring(0, 15) + " ... " + url.substring(
 				(url.length() - 15), url.length()));
 			}
 			//out.print(url);
 		}
 %>
	</td>
	<td>
	
			<%

ShowLinkCapability linkCapab=new ShowLinkCapability();
CapabilityLinkBean[]links=linkCapab.showCapabilityLink(ds,testCode,false);
//Map<MyClass.Key, String> data = (HashMap<MyClass.Key, String>) getData();


	String[] allPossibleCapabilities = Capabilities
			.getCapabilitesInCoreOrder();
	
	//loop over all possible capabilities for a das server in the order we want as specified by the getCapabilitiesInCoreOrder
	for (int allCapsIndex = 0; allCapsIndex < allPossibleCapabilities.length; allCapsIndex++) {
		CapabilityLinkBean bean=links[allCapsIndex];
		//CapabilityLinkBean bean=links.
	
		
	}//end of looping over all capabilities
%>	
			
	</td>

	<td>
	<%
				for (int j = 0; j < coordSys.length; j++) {
				DasCoordinateSystem cs = coordSys[j];
	%><a href="coordsys/<%=cs.getUniqueId() %>"><%=cs.toString()%></a>
					<%
					}
					%>
	</td>

	<td>
	
	<%
				// make compact and expandable display of description;

				int displength = 0;
				int longlength = 0;

				String desc = ds.getDescription();

				if (desc.length() > longlength) {
		%><%=desc.substring(0, displength)%><span id="rcc-<%=i%>"><a href="#rev" onclick="document.getElementById('rcc-<%=i%>').style.display = 'none'; document.getElementById('rce-<%=i%>').style.display = 'inline'; return false;">show&nbsp;&gt;</a></span><span id="rce-<%=i%>" style="display: none"><%=desc.substring(displength, desc.length())%></span>
		<%
		} else {
		%>
		<%=desc%>
		<%
		}
		%>
	
	<%
				String helperurl = ds.getHelperurl();
				if ((helperurl != null) && (!helperurl.equals(""))) {
		%><div title="header=[get more information] body=[show me more information about this DAS source in another window]"> 
			<a href="javascript:openWindow('<%=helperurl%>','',640,480)">go&nbsp;to&nbsp;site</a>
			</div> 
			<%
 			}
 			%>
	</td>
	
	<td>
	<%
	ProjectBean tp = coord.getProjectBeanForURL(ds.getUrl());
	if (tp != null) {
		%>
		<div title="header=[<%= tp.getName() %>] body=[<%=tp.getDescription() %>]">
		<a href="showProjectDetails.jsp?project_id=<%=tp.getProjectID() %>"><img src="<%= tp.getIconURL()%>"/></a></div><%
	}
%>
	
	</td>
	
	</tr>

	<%
	}
	%>


<% 
// if logged in the user can do more with the DAS sources
if ( email != null ) {
	
	%></form><% 	
}
%>



<%@ include file="listbrowser.jsp"%>
<%@ include file="sangertableend.jsp"%>
